package lhc.alg.top100;

/**
 * description: https://leetcode.cn/problems/maximum-subarray/
 *  最大子数组和  动态规划 weiwei的题解写的真不错啊
 * author: hongchen.liao
 * date:  2022/9/20
 */
public class _53_ {
    class Solution {
        public int maxSubArray(int[] nums) {
            int prev = 0, ans = nums[0];
            for(int e : nums){
                prev = Math.max(e, prev+e);
                ans = Math.max(ans, prev);
            }
            return ans;
        }
    }

}
